package com.ocss.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ocss.system.domain.OcssCourse;
import com.ocss.system.domain.OcssStudent;
import com.ocss.system.domain.vo.CourseStudentAchievementVo;
import com.ocss.system.domain.vo.StudentCourseAchievementVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ocss.common.annotation.Log;
import com.ocss.common.core.controller.BaseController;
import com.ocss.common.core.domain.AjaxResult;
import com.ocss.common.enums.BusinessType;
import com.ocss.system.domain.OcssAchievement;
import com.ocss.system.service.IOcssAchievementService;
import com.ocss.common.utils.poi.ExcelUtil;
import com.ocss.common.core.page.TableDataInfo;

/**
 * 成绩管理Controller
 *
 * @author ligen
 * @date 2024-03-09
 */
@RestController
@RequestMapping("/system/achievement")
public class OcssAchievementController extends BaseController {
    @Autowired
    private IOcssAchievementService ocssAchievementService;

    /**
     * 查询教师的课程列表
     */
    @PreAuthorize("@ss.hasPermi('system:achievement:list')")
    @GetMapping("/teacherCourseList")
    public TableDataInfo teacherList(OcssCourse ocssCourse) {
        startPage();
        List<OcssCourse> list = ocssAchievementService.selectTeacherCourseList(ocssCourse);
        return getDataTable(list);
    }

    /**
     * 查询学生的课程列表
     */
    @PreAuthorize("@ss.hasPermi('system:achievement:list')")
    @GetMapping("/studentCourseList")
    public TableDataInfo studentList(OcssCourse ocssCourse) {
        startPage();
        List<StudentCourseAchievementVo> list = ocssAchievementService.selectStudentCourseList(ocssCourse);
        return getDataTable(list);
    }


    /**
     * 查询该课程中的学生
     */
    @PreAuthorize("@ss.hasPermi('system:achievement:list')")
    @GetMapping("/courseStudentList/{id}")
    public TableDataInfo courseStudentList(OcssStudent student, @PathVariable("id") Long id) {
        startPage();
        List<CourseStudentAchievementVo> list = ocssAchievementService.selectCourseStudentList(student, id);
        return getDataTable(list);
    }

    /**
     * 录入成绩
     */
    @PreAuthorize("@ss.hasPermi('system:achievement:add')")
    @PostMapping
    public AjaxResult add(@RequestBody OcssAchievement ocssAchievement) {
        return toAjax(ocssAchievementService.insertOcssAchievement(ocssAchievement));
    }

}
